home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue47 / OOPRules / inher.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-05-03  |  934 b   |  48 lines

  1. unit inher;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   frm2, StdCtrls;
  8.  
  9. type
  10.   TFormInherit = class(TFormDialog)
  11.     procedure ButtonClearClick(Sender: TObject);
  12.     procedure FormCreate(Sender: TObject);
  13.   private
  14.     ButtonClear: TButton;
  15.   protected
  16.     procedure SetText(const Value: String); override;
  17.   end;
  18.  
  19. implementation
  20.  
  21. {$R *.DFM}
  22.  
  23. procedure TFormInherit.ButtonClearClick(Sender: TObject);
  24. begin
  25.   inherited;
  26.   // Edit1.Text := '';  // illegal
  27.   // SetText ('');
  28.   Text := '';
  29. end;
  30.  
  31. procedure TFormInherit.FormCreate(Sender: TObject);
  32. begin
  33.   inherited;
  34.   ButtonClear := FindComponent ('ButtonClear') as TButton;
  35. end;
  36.  
  37. procedure TFormInherit.SetText(const Value: String);
  38. begin
  39.   inherited SetText (Value);
  40.   if Value = '' then
  41.     ButtonClear.Enabled := False;
  42. end;
  43.  
  44. initialization
  45.   RegisterClasses ([
  46.     TButton]);
  47. end.
  48.